home *** CD-ROM | disk | FTP | other *** search
/ Mastering Microsoft Visual Basic 5 / Mastering Microsoft Visual Basic 5.ISO / demo code / ch05 / callback / module1.bas < prev    next >
Encoding:
BASIC Source File  |  1997-01-07  |  707 b   |  22 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3. Declare Function EnumChildWindows Lib "user32" _
  4.   (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, _
  5.   ByVal lParam As Long) As Boolean
  6. Declare Function GetWindowText Lib "user32" _
  7.   Alias "GetWindowTextA" _
  8.   (ByVal hwnd As Long, ByVal lpString As String, _
  9.   ByVal cch As Long) As Long
  10.  
  11. Public Function EnumFunc(ByVal hWndChild As Long, _
  12.   ByVal lParam As Long) As Boolean
  13.   Dim size As Long
  14.   Dim s As String
  15.   s = String(255, 0)
  16.   size = GetWindowText(hWndChild, s, Len(s))
  17.   s = Left$(s, size)
  18.   Form1.List1.AddItem s       ' Add caption to Listbox
  19.   EnumFunc = True             ' Return FALSE to halt enumeration
  20. End Function
  21.  
  22.